#!/bin/bash
#wget http://download.safedog.cn/safedog_linux64.tar.gz
source ./var
source ./Tmpdir
Install_server_safedog(){
    Safedog_Version="server_safedog_linux64.tar.gz"
    TAR_Version="safedog_an_linux64_2.8.21207"
    sdcloud -v &> /dev/null
    [ $? = 0 ] && echoYellow "server_afedog已安装，即将退出" && exit 6
    #调用Tmpdir
    Tmpdir
    cd $dir && wget -V &> /dev/null || yum -y install wget
    #chattr -i /sbin/
    #chattr -i /usr/sbin/
    #chattr -i /bin/
    #chattr -i /sbin/
    #chattr -i /usr/lib
    #chattr -i /usr/lib64/
    #chattr -i /usr/libexec/
    #chattr -i /etc/passwd /etc/group /etc/shadow /etc/gshadow
    #安装依赖包
    yum install -y mlocate lsof pciutils dmidecode wget psmisc

    wget $ip/${Safedog_Version} && tar -xzf ${Safedog_Version} && chmod +x ./${TAR_Version}/install.py && ./${TAR_Version}/install.py
    [ $? != 0 ] && echoRed "编译失败，即将退出" && rm -rf $dir && exit 8
    if sdcloud -v &> /dev/null;then
       echoYellow "server_safedog已安装，请手动登录"
       [ -d $dir ] && rm -rf $dir
    else
       echoGreen "server_safedog未安装成功，即将退出"
       [ -d $dir ] && rm -rf $dir
    fi
}
Install_server_safedog
